<h5>Comment Field</h5>
  <div class="field">
    <%= label_tag 'commente user' %><br>
    <%= text_field_tag 'comment[user]' %>
  </div>
  <div class="field">
    <%= label_tag 'comment body' %><br>
    <%= text_area_tag 'comment[body]' %>
  </div>
  <div class="actions">
    <%= hidden_field_tag 'comment_from', 2 %>
    <%= button_tag 'Submit Comment', class:'submit_comment', "data-submit-url"=> ajax_create_comment_comments_path %>
  </div>

<script type="text/javascript">
  $('.submit_comment').click(function(){
    var commentUser = $('#comment_user').val();
    var commentBody = $('#comment_body').val();
    var submitUrl = $(this).data('submit-url');
    var commentFrom = $('#comment_from').val();
    var fromId = $('#from_id').val();
    $.ajax({
      url: submitUrl,
      type: 'post',
      data: {user: commentUser, body: commentBody, comment_from: commentFrom, from_id: fromId},
      success: function(){
        $('#comment_user').val('');
        $('#comment_body').val('');
        alert('comment success!');
      }
    })
  })
</script>
